<template>
	<view class="index page">
		<view class="header">
			<nav-bar title="授权登录">
			</nav-bar>
		</view>
		<view class="main">
			<view class="logo">
				<image src="" mode="heightFix"></image>
			</view>
			<view class="title">人文警务申请获得以下权限</view>
			<view class="label">获得您的公开信息(昵称，头像等)</view>
			<view class="user-auth-btn">
				<button open-type="getAuthorize" scope="phoneNumber" @getAuthorize="getPhoneNumber">授权登录</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		Login
	} from "@/common/api/common_api.js"
	export default {
		data() {
			return {

			}
		},
		methods: {
			getPhoneNumber() {
				console.log('授权')
				uni.showLoading({
					title: '加载中...'
				})
				uni.login({
					provider: "alipay",
					scopes: "auth_user",
					success: (res) => {
						// console.log(res.result.code,'===========code============')
						Login({authCode:'ed08e58d49ec4689b8da25b33181e5000d330201'})
							.then((res) => {
								console.log(res,'========login==========');
								uni.setStorageSync("token", res.data);
								uni.reLaunch({
									url: '/pages/index/index'
								})
							})
							.catch((error) => {})
					},
					complete: (res) => {
						console.log("=========login complete========")
						uni.hideLoading();
					}
				})  
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/common/style/common.scss";

	.index {
		@include flex-c;

		>.header {
			flex: 0 0 auto;
		}

		>.main {
			text-align: center;
			padding: 250rpx 32rpx 0;

			.logo {
				height: 180rpx;
				margin: 0 auto 64rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.title {
				font-weight: bold;
				font-size: 32rpx;
				padding-bottom: 24rpx;
			}

			.label {
				font-size: 24rpx;
				color: #9B9B9B;
				padding-bottom: 150rpx;
			}

			.user-auth-btn {
				padding: 24rpx;

				button {
					width: max-content;
					padding: 0;
					margin: 0;
					outline: none;
					border: none;
					border-radius: 40rpx;
					width: 100%;
					height: 85rpx;
					line-height: 85rpx;
					font-size: 28rpx;
					font-weight: normal;
					color: #fff;
					background-color: #EA5257;
					&::after {
						display: none;
					}
				}
			}
		}
	}
</style>
